package com.imay.live.adapter;


import android.text.method.LinkMovementMethod;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.imay.live.R;
import com.imay.live.logic.NoticeListLogic;
import com.imay.live.model.NoticeMergeMineModel;
import com.imay.live.utils.GlideUtil;

import java.util.List;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

/**
 * Created by  nick on 2017/4/5 0005.
 * 通知, 我的,合并消息列表
 */

public class NoticeMergeListMineAdapter extends  BaseQuickAdapter<NoticeMergeMineModel, BaseViewHolder> {

    public NoticeMergeListMineAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, NoticeMergeMineModel item) {
        ImageView iv_notice_right = helper.getView(R.id.iv_notice_right);
        ImageView iv_notice_head_img = helper.getView(R.id.iv_notice_head_img);
        helper.setText(R.id.tv_notice_content,NoticeListLogic.getTextMineMerge(mContext,item));

        ((TextView)helper.getView(R.id.tv_notice_content)).setMovementMethod(LinkMovementMethod.getInstance());//设置点击监听
        GlideUtil.loadCircleImage(iv_notice_head_img,item.getUser().getImgHead(),R.mipmap.pnl_00_head108);
        iv_notice_right.setVisibility(GONE);
        if (item.getEventType()!=1){
            if (item.getFeed()!=null){
                GlideUtil.loadCircleImage(iv_notice_right,item.getFeed().getUrl(),R.mipmap.placeholder);
                iv_notice_right.setVisibility(VISIBLE);
            }
        }

        helper.setVisible(R.id.iv_notice_right,item.getEventType()!=1);
        helper.setVisible(R.id.cb_notice_follow,item.getEventType()==1);
        if (item.getEventType()==1){
            helper.setChecked(R.id.cb_notice_follow,item.getUser().isMyFollow());
            helper.setVisible(R.id.cb_notice_follow,!item.getUser().isMyFollow());
        }

        helper.addOnClickListener(R.id.iv_notice_head_img);
        helper.addOnClickListener(R.id.iv_notice_right);
        helper.addOnClickListener(R.id.cb_notice_follow);




    }





}
